<script setup>
import zhCN from 'ant-design-vue/es/locale/zh_CN';
import enUS from 'ant-design-vue/es/locale/en_US'; // 英文语言包
import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';
import { watch, ref } from 'vue';
import { provide } from 'vue';

dayjs.locale('zh-CN');

const isCN = ref(true)
watch(isCN, newVal => {
  dayjs.locale(newVal === true ? 'zh-CN' : 'en');
});
// 用provide,inject传递数据
provide('isCN', isCN)
provide('changeLanguage', (iscn) => {
  isCN.value = iscn
})

</script>
<template>
  <a-config-provider :locale="isCN === true ? zhCN : enUS">
    <div class="app">
      <router-view></router-view>
    </div>
  </a-config-provider>
</template>
<style scoped lang="less">
.app {
  height: 100vh;
}
</style>
